package joe.works.cacheimpl;

import java.util.ArrayList;
import java.util.List;

import joe.works.cache.CacheEvent;
import joe.works.cache.ICahceListener;

/**
 * A composite delegate implementation of {@link ICahceListener}
 * @author josseyj
 *
 */
public class CompositeCacheListener implements ICahceListener {
	private List<ICahceListener> listeners = new ArrayList<ICahceListener>();
	
	public void cacheUpdated(CacheEvent<?> cacheEvent) {
		for(ICahceListener listener : listeners) {
			listener.cacheUpdated(cacheEvent);
		}
	}
	
	public void addListener(ICahceListener listener) {
		listeners.add(listener);
	}

	public void removeListener(ICahceListener listener) {
		listeners.remove(listener);
	}
	
	public void clear() {
		listeners.clear();
	}

}
